/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.Videominuto.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JULIAN
 */
@Entity
@Table(name = "serie")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Serie.findAll", query = "SELECT s FROM Serie s"),
    @NamedQuery(name = "Serie.findByIsanSerie", query = "SELECT s FROM Serie s WHERE s.isanSerie = :isanSerie"),
    @NamedQuery(name = "Serie.findByTitulo", query = "SELECT s FROM Serie s WHERE s.titulo = :titulo"),
    @NamedQuery(name = "Serie.findByTemporada", query = "SELECT s FROM Serie s WHERE s.temporada = :temporada")})
public class Serie implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "isan_serie")
    private Integer isanSerie;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "temporada")
    private int temporada;
    @JoinTable(name = "serie_video", joinColumns = {
        @JoinColumn(name = "isan_serie", referencedColumnName = "isan_serie")}, inverseJoinColumns = {
        @JoinColumn(name = "isan_vdi", referencedColumnName = "isan_video")})
    @ManyToMany
    private List<Video> videoList;
    @JoinColumn(name = "id_protagonista", referencedColumnName = "id_persona")
    @ManyToOne(optional = false)
    private Persona idProtagonista;

    public Serie() {
    }

    public Serie(Integer isanSerie) {
        this.isanSerie = isanSerie;
    }

    public Serie(Integer isanSerie, String titulo, int temporada) {
        this.isanSerie = isanSerie;
        this.titulo = titulo;
        this.temporada = temporada;
    }

    public Integer getIsanSerie() {
        return isanSerie;
    }

    public void setIsanSerie(Integer isanSerie) {
        this.isanSerie = isanSerie;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public int getTemporada() {
        return temporada;
    }

    public void setTemporada(int temporada) {
        this.temporada = temporada;
    }

    @XmlTransient
    public List<Video> getVideoList() {
        return videoList;
    }

    public void setVideoList(List<Video> videoList) {
        this.videoList = videoList;
    }

    public Persona getIdProtagonista() {
        return idProtagonista;
    }

    public void setIdProtagonista(Persona idProtagonista) {
        this.idProtagonista = idProtagonista;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (isanSerie != null ? isanSerie.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Serie)) {
            return false;
        }
        Serie other = (Serie) object;
        if ((this.isanSerie == null && other.isanSerie != null) || (this.isanSerie != null && !this.isanSerie.equals(other.isanSerie))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.uniminuto.Videominuto.entities.Serie[ isanSerie=" + isanSerie + " ]";
    }
    
}
